
package com.scalar;

import java.io.PrintStream;
import java.io.PrintWriter;


public class ScalarException extends Exception {

    private Throwable m_rootCause = null;

    public ScalarException() {
        super();
    }

    public ScalarException (String errMessage) {
        super (errMessage);
    }

    public ScalarException (String errMessage, Throwable rootCause) {
        super (errMessage);
        m_rootCause = rootCause;
    }

    public Throwable getRootCause() {
        if (m_rootCause != null) {
            return m_rootCause;
        }
        
        return this;
    }
    
    public void printStackTrace() {
        if (m_rootCause != null) {
            m_rootCause.printStackTrace();
        }
        
        super.printStackTrace();
    }
    
    public void printStackTrace(PrintStream ps) {
        if (m_rootCause != null) {
            m_rootCause.printStackTrace (ps);
        }
        
        super.printStackTrace (ps);
    }
    
    public void printStackTrace (PrintWriter pw) {
        if (m_rootCause != null) {
            m_rootCause.printStackTrace (pw);
        }
        
        super.printStackTrace (pw);
    }
}